<?php
class ConfigAction extends Action {
    //首页
	public function index(){
		$isLogin = session(C('ADMIN_AUTH_KEY'));
		if(!$isLogin) $this->redirect('User/login');
		$model=D('Config');
		$fid=$model->find();
		if(strtolower($_SERVER['REQUEST_METHOD']) == 'post')
		{
			$cond = $_POST;
			$cond['confid'] = 1;
			if($model->create($cond)){   
				if(empty($fid)){
				  $model->add();
				}else {
					$model->save();
					}
				$this->assign('erorsta','2');
				$this->assign('error',"保存成功");
			}else{   
				$rs['error'] = $model->getError();
				$this->assign('erorsta','1');
				$this->assign('error',$rs['error']);
			}
	    $fid=$model->find();
		}
		$this->assign('fid',$fid);
		$this->display();
	}
}